package gui.entity;

import generated.domain.room.Room;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;

public class RoomElementPropertySource implements IPropertySource {

	private static final String PROPERTY_ID_NAME = "room.name";
	private static final Object PROPERTY_ID_ABSCISSA = "room.location.x";
	private static final Object PROPERTY_ID_ORDINATE = "room.location.y";
	private static final Object PROPERTY_ID_NORTH_GATE = "room.north.gate";
	private static final Object PROPERTY_ID_SOUTH_GATE = "room.south.gate";
	private static final Object PROPERTY_ID_EAST_GATE = "room.east.gate";
	private static final Object PROPERTY_ID_WEST_GATE = "room.west.gate";
	private final Room room;

	private IPropertyDescriptor[] propertyDescriptors;

	public RoomElementPropertySource(RoomEntity element) {
		room = element.getRoom();
	}

	public IPropertyDescriptor[] getPropertyDescriptors() {
		if (propertyDescriptors == null) {
			PropertyDescriptor nameDescriptor = new PropertyDescriptor(
					PROPERTY_ID_NAME, "Name");

			PropertyDescriptor abscissaDescriptor = new PropertyDescriptor(
					PROPERTY_ID_ABSCISSA, "Abscissa");

			PropertyDescriptor ordinateDescriptor = new PropertyDescriptor(
					PROPERTY_ID_ORDINATE, "Ordinate");

			PropertyDescriptor northGateDescriptor = new PropertyDescriptor(
					PROPERTY_ID_NORTH_GATE, "North Gate");

			PropertyDescriptor southGateDescriptor = new PropertyDescriptor(
					PROPERTY_ID_SOUTH_GATE, "South Gate");

			PropertyDescriptor eastGateDescriptor = new PropertyDescriptor(
					PROPERTY_ID_EAST_GATE, "East Gate");

			PropertyDescriptor westGateDescriptor = new PropertyDescriptor(
					PROPERTY_ID_WEST_GATE, "West Gate");

			propertyDescriptors = new IPropertyDescriptor[] { nameDescriptor,
					abscissaDescriptor, ordinateDescriptor,
					northGateDescriptor, southGateDescriptor,
					eastGateDescriptor, westGateDescriptor };
		}
		return propertyDescriptors;
	}

	public Object getEditableValue() {
		return null;
	}

	public Object getPropertyValue(Object id) {
		if (id.equals(PROPERTY_ID_NAME))
			return room.name;
		if (id.equals(PROPERTY_ID_ABSCISSA))
			return room.location.x;
		if (id.equals(PROPERTY_ID_ORDINATE))
			return room.location.y;
		if (id.equals(PROPERTY_ID_NORTH_GATE))
			return room.northGate;
		if (id.equals(PROPERTY_ID_SOUTH_GATE))
			return room.southGate;
		if (id.equals(PROPERTY_ID_EAST_GATE))
			return room.eastGate;
		if (id.equals(PROPERTY_ID_WEST_GATE))
			return room.westGate;
		return "";
	}

	public boolean isPropertySet(Object id) {
		// TODO Auto-generated method stub
		return false;
	}

	public void resetPropertyValue(Object id) {
		// TODO Auto-generated method stub

	}

	public void setPropertyValue(Object id, Object value) {
		// TODO Auto-generated method stub

	}
}